<?php
$title='黑名单列表';
include 'header.php';
$id=daddslashes($_GET["id"]);
$type=$pdo->query("SELECT * FROM 9g_type WHERE `id`='{$id}'")->fetch()["type"];
?>
<!--页面主要内容-->
<link href="../assets/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css">
<link href="../assets/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css">
<link href="../assets/css/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css">
<link href="../assets/css/sweetalert2.min.css" rel="stylesheet" type="text/css">
<div class="main-content">
            <div class="page-content">
                <div class="container-fluid">
                    <!-- start page title -->
                    <div class="row">
                        <div class="col-12">
                            <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                                <h4 class="mb-sm-0">黑名单列表【当前显示得的是记录类型为<?php echo $type; ?>的信息】</h4>
                                <div class="page-title-right">
                                    <ol class="breadcrumb m-0">
                                        <li class="breadcrumb-item"><a href="javascript: void(0);">团队管理</a></li>
                                        <li class="breadcrumb-item active">黑名单列表</li>
                                    </ol>
                                </div>
                            </div>
                        </div>
                    </div><!-- end page title -->
                    <div class="row">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-body">
                                    <p class="card-title-desc">
                                        <button type="button" onclick="window.location.href='addinfo.php';" class="btn btn-success waves-effect waves-light"><i class="ri-user-add-line align-middle me-2"></i>添加黑名单</button> 
                                        <button type="button" onclick="return deletess()" class="btn btn-danger waves-effect waves-light"><i class="ri-delete-bin-6-line align-middle me-2"></i>清空</button>
                                    </p>
                                    <table id="datatable" class="table table-bordered dt-responsive nowrap"
                                        style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                                        <thead>
                                            <tr>
                                                 <th>收录信息</th>
                                                <th>举报者邮箱</th>
                                                <th>创建时间</th>
                                                <th>审核状态</th>
                                                     <th>提交状态</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                              function data_act($data){
                                            $s=explode("||",$data);
                                            foreach($s as $k=>$v){
                                            $x.='<p style="color:red">'.$v.'</p>';
                                             }
                                            return $x;
                                        }
                                          function status_if($status,$id,$email){
                                            if($status==1){
                                                return '<span class="badge badge-soft-success">已审核</span>';
                                            }else{
                                                return '<span onclick="return actinfo('.$id.',\''.$email.'\');" class="badge badge-soft-warning">未审核</span>';
                                            }
                                        }
                                               function sl_if($status,$id){
                                            if($status==1){
                                                return '<span class="badge badge-soft-success">已提交收录</span>';
                                            }else{
                                                return '<span onclick="return actsl('.$id.');" class="badge badge-soft-warning">未提交收录</span>';
                                            }
                                        }
                                        try {
                                            $query=$pdo->query("SELECT * FROM 9g_msg WHERE `type`='{$id}'");
                                            while($row=$query->fetch(PDO::FETCH_ASSOC)){
                                                echo '<tr>
                                                 <td>'.data_act($row["data"]).'</td>
                                                <td>'.$row["user"].'</td>
                                                <td>'.$row["time"].'</td>
                                                <td>'.status_if($row["status"],$row["id"],$row["user"]).'</td>
                                                <td>'.sl_if($row["sl"],$row["id"]).'</td>
                                                 <td>
                                                <a href="upinfo.php?id='.$row["id"].'" class="btn btn-outline-secondary btn-sm edit" title="编辑">
                                                    <i class="fas fa-pencil-alt" title="编辑"></i>
                                                </a>
                                                <a href="lookinfo.php?id='.$row["id"].'" class="btn btn-outline-secondary btn-sm edit" title="预览">
                                                <i class=" ri-eye-line " title="预览"></i>
                                            </a>
                                                <button  onclick="return deletes('.$row["id"].')" class="btn btn-outline-secondary btn-sm edit" title="删除">
                                                    <i class="ri-delete-bin-7-line " title="删除"></i>
                                                </a>
                                            </td>
                                            </tr>';
                                            }
                                            $pdo=null;
                                            $query=null;
                                        } catch (\Throwable $th) {
                                            //throw $th;
                                        }
                                        ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div><!-- end col -->
                    </div><!-- end row -->
                </div><!-- container-fluid -->
            </div><!-- End Page-content -->
            <footer class="footer">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-6">
                    <script>
                        document.write(new Date().getFullYear())
                    </script>(c) Cloud.
                </div>
                <div class="col-sm-6">
                    <div class="text-sm-end d-none d-sm-block">Crafted with <i class="mdi mdi-heart text-danger"></i>By <a href="https://www.9gyun.cn">云风轻产品授权中心</a></div>
                </div>
            </div>
        </div>
    </footer>
        </div><!-- end main content-->
    </div><!-- END layout-wrapper -->
    <!-- Right Sidebar -->
    <!-- Right bar overlay-->
    <div class="rightbar-overlay"></div><!-- JAVASCRIPT -->
    <script src="../assets/js/jquery.min.js"></script>
    <script src="../assets/js/bootstrap.bundle.min.js"></script>
    <script src="../assets/js/metisMenu.min.js"></script>
    <script src="../assets/js/simplebar.min.js"></script>
    <script src="../assets/js/waves.min.js"></script><!-- Required datatable js -->
    <script src="../assets/js/jquery.dataTables.min.js"></script>
    <script src="../assets/js/dataTables.bootstrap4.min.js"></script><!-- Buttons examples -->
    <script src="../assets/js/dataTables.buttons.min.js"></script>
    <script src="../assets/js/buttons.bootstrap4.min.js"></script>
    <script src="../assets/js/jszip.min.js"></script>
    <script src="../assets/js/pdfmake.min.js"></script>
    <script src="../assets/js/vfs_fonts.js"></script>
    <script src="../assets/js/buttons.html5.min.js"></script>
    <script src="../assets/js/buttons.print.min.js"></script>
    <script src="../assets/js/buttons.colVis.min.js"></script><!-- Responsive examples -->
    <script src="../assets/js/dataTables.responsive.min.js"></script>
    <script src="../assets/js/responsive.bootstrap4.min.js"></script><!-- Datatable init js -->
    <script src="../assets/js/datatables.init.js"></script>
    <script src="../assets/js/app.js"></script>
    <script src="../assets/js/sweetalert2.min.js"></script>
<script language="JavaScript">
        function deletes(del) {
        var id = del;
        Swal.fire({
    title: '你确定要删除此条数据吗?',
    text: "删除后将不可恢复!",
    icon: 'warning',
    showCancelButton: true,
    confirmButtonText: '是的，删除它',
    cancelButtonText: '点错了',
    confirmButtonClass: 'btn btn-success mt-2',
    cancelButtonClass: 'btn btn-danger ms-2 mt-2',
    buttonsStyling: false
  }).then(function(result) {
    if (result.value) {
        $.ajax({
            type: "POST",
            url: "set.php?act=delinfo",
            data: {
                id: id
            },
            dataType: "json",
            success: function(data) {
                if (data.state == 1) {
                    Swal.fire("删除成功!", "恭喜你，删除成功!", "success");
                    setTimeout(function() {
                        window.location = './infolist.php';
                    }, 1000);
                }else{
                    Swal.fire("删除失败!", "删除失败!", "error");
                }

            },
            error: function(data) {

            }
        });
    } else if (
      // Read more about handling dismissals
      result.dismiss === Swal.DismissReason.cancel
    ) {
        return false;
    }
  });
}
    function deletess(){
        Swal.fire({
    title: '敏感操作！',
    text: "你是否要删除全部记录？",
    icon: 'warning',
    showCancelButton: true,
    confirmButtonText: '是的',
    cancelButtonText: '点错了',
    confirmButtonClass: 'btn btn-success mt-2',
    cancelButtonClass: 'btn btn-danger ms-2 mt-2',
    buttonsStyling: false
  }).then(function(result) {
    if (result.value) {
        $.ajax({
            type: "POST",
            url: "set.php?act=delsinfo",
            data: {
               act:'act'
            },
            dataType: "json",
            success: function(data) {
                if (data.state == 1) {
                    Swal.fire("清空成功!", "恭喜你，清空成功了!", "success");
                    setTimeout(function() {
                        window.location = './infolist.php';
                    }, 1000);
                }else{
                    Swal.fire("清空失败!", "清空失败，可能无信息!", "error");
                }

            },
            error: function(data) {

            }
        });
    }
  });
 }
 function actinfo(id,email){
    Swal.fire({
    title: '是否审核通过?',
    text: "是否审核通过此申请!",
    icon: 'warning',
    showCancelButton: true,
    confirmButtonText: '通过!',
    cancelButtonText: '不通过!',
    confirmButtonClass: 'btn btn-success mt-2',
    cancelButtonClass: 'btn btn-danger ms-2 mt-2',
    buttonsStyling: false
  }).then(function(result) {
    if (result.value) {
        $.ajax({
            type: "POST",
            url: "set.php?act=actinfo",
            data: {
                id:id
            },
            dataType: "json",
            success: function(data) {
            },
        });
        Swal.fire({
    title: '是否发送邮件通知?',
    text: "是否通过申请后发送邮件至举报者邮箱!",
    icon: 'warning',
    showCancelButton: true,
    confirmButtonText: '是的!',
    cancelButtonText: '算了吧!',
    confirmButtonClass: 'btn btn-success mt-2',
    cancelButtonClass: 'btn btn-danger ms-2 mt-2',
    buttonsStyling: false
  }).then(function(results) {
    if (results.value) {
        $.ajax({
            type: "POST",
            url: "set.php?act=tgemail",
            data: {
                email:email
            },
            dataType: "json",
            success: function(data) {
            },
        });
      Swal.fire({
        title: '发送成功!',
        text: '恭喜你，发送至对方邮箱成功！',
        icon: 'success'
      })
      window.location.href='infolisttype.php';
    } else if (
      // Read more about handling dismissals
      results.dismiss === Swal.DismissReason.cancel
    ) {
        return false;
    }
  });
    } else if (
      // Read more about handling dismissals
      result.dismiss === Swal.DismissReason.cancel
    ) {
        $.ajax({
            type: "POST",
            url: "set.php?act=delinfo",
            data: {
                id:id
            },
            dataType: "json",
            success: function(data) {
            },
        });
        Swal.fire({
    title: '请输入审核不通过理由',
    input: 'text',
    showCancelButton: true,
    confirmButtonText: 'Submit',
    showLoaderOnConfirm: true,
    confirmButtonColor: "#5664d2",
    cancelButtonColor: "#ff3d60",
    preConfirm: function(text) {
        $.ajax({
            type: "POST",
            url: "set.php?act=btgemail",
            data: {
                email:email,
                msg:text
            },
            dataType: "json",
            success: function(data) {
            },
        });
        Swal.fire({
      icon: 'success',
      title: '发送成功，此记录已经删除!',
      confirmButtonColor: "#5664d2",
    })
    window.location.href='infolisttype.php';
    },
    allowOutsideClick: false
  }).then(function(email) {
    Swal.fire({
      icon: 'info',
      title: '此记录已经删除!',
      confirmButtonColor: "#5664d2",
    });
    window.location.href='infolisttype.php';
  })
    }
  });
 }
  function actsl(id){
        Swal.fire({
    title: '你要重新提交收录吗?',
    text: "是否尝试重新提交!",
    icon: 'warning',
    showCancelButton: true,
    confirmButtonText: '是的',
    cancelButtonText: '点错了',
    confirmButtonClass: 'btn btn-success mt-2',
    cancelButtonClass: 'btn btn-danger ms-2 mt-2',
    buttonsStyling: false
  }).then(function(result) {
    if (result.value) {
        $.ajax({
            type: "POST",
            url: "set.php?act=actsl",
            data: {
                id: id
            },
            dataType: "json",
            success: function(data) {
                if (data.state == 1) {
                    Swal.fire("删除成功!", "恭喜你，提交成功!", "success");
                    setTimeout(function() {
                        window.location = './infolisto.php';
                    }, 1000);
                }else{
                    Swal.fire("提交失败!", "可能是今日提交上限或配置的token有错误!", "error");
                }

            },
            error: function(data) {

            }
        });
    } else if (
      // Read more about handling dismissals
      result.dismiss === Swal.DismissReason.cancel
    ) {
        return false;
    }
  });
 }
</script>
</body>
</html>